import request from '@/utils/request'
export const getArticleList = (id, timestamp) => {
  return request({
    method: 'get',
    url: '/v1_1/articles',
    params: {
      channel_id: id,
      timestamp,
      with_top: 1
    }
  })
}
/**
 * 对于不喜欢的文章
 * @param {*} id
 * @returns
 */
export function dislikeArticle(id) {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}
/**
 * 举报文章接口
 * @param {*} id
 * @param {*} type
 * @returns
 */
export function reportsApi(id, type) {
  return request({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target: id,
      type
    }
  })
}

/**
 * 获取新闻详情
 * @param {*} id 文章id
 * @returns
 */
export function reqGetNewDetails(id) {
  return request({
    method: 'get',
    url: `/v1_0/articles/${id}`
  })
}
/**
 * 关注用户
 * @param {*} target 关注用户的id
 * @returns
 */
export function followUser(target) {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
/**
 * 取消关注用户
 * @param {*} id 取消关注用户的id
 * @returns
 */
export function unfollowUser(id) {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + id
  })
}

/**
 * 取消点赞
 * @param {*} id 文章编号
 */
export const deleteLike = id => {
  return request({
    method: 'delete',
    url: '/v1_0/article/likings/' + id
  })
}

/**
 * 添加点赞
 * @param {*} id 文章编号
 */
export const addLike = id => {
  return request({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}

/**
 * 取消不喜欢
 * @param {*} id 文章编号
 */
export const reqDeleteDisLike = id => {
  return request({
    method: 'delete',
    url: '/v1_0/article/dislikes/' + id
  })
}

/**
 * 添加不喜欢
 * @param {*} id 文章编号
 */
export const reqAddDisLike = id => {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}

/**
 * 获取评论列表
 * @param {*} type
 * @param {*} source
 * @param {*} offset
 * @returns
 */
export function reqGetComment(type, source, offset) {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type,
      source,
      offset
    }
  })
}
/**
 * 添加评论
 * @param {*} target
 * @param {*} content
 * @returns
 */
export function reqAddComment(target, content) {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target,
      content

    }
  })
}
/**
 * 对评论进行点赞
 * @param {*} target tags的id
 * @returns
 */
export function reqCommentTag(target) {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target
    }

  })
}
/**
 * 取消对评论点赞
 * @param {*} target tag的id
 * @returns
 */
export function reqCancelCommentTag(target) {
  return request({
    method: 'DELETE',
    url: '/v1_0/comment/likings/' + target

  })
}
/**
 * 获取评论的回复
 * @param {*} type ，c-对评论(comment)的回复
 * @param {*} source cm_id 评论的id
 * @param {*} offset 	获取评论数据的偏移量，值为评论id，表示从此id的数据向后取，不传表示从第一页开始读取数据
 * @returns
 */
export function reqGetCommentReply(type, source, offset) {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type,
      source,
      offset
    }
  })
}
/**
 *
 * @param {*} target 评论id
 * @param {*} content 评论内容
 * @param {*} art_id 文章id
 * @returns
 */
export function reqAddCommentReply(target, content, art_id) {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target,
      content,
      art_id

    }
  })
}
